In recent years, object-oriented programming languages such as Java™ have become increasingly popular for a wide variety of applications running on many different types of platforms. Many such programming languages support overloading of invocable operations such as methods and constructors, allowing programmers to create several methods with the same name within a given class, or several constructors for a given class. Within a given set of overloaded invocable operations, the individual operations may differ from one another in various ways—e.g., in the number of parameters, the types of the parameters, or the return types in the case of methods. Support for overloading relieves programmers of the burden of having to make up different names for methods or constructors that provide similar functionality, and therefore should ideally not be forced to have different names. Compilers (or other tools that perform type checking, such as certain kinds of interpreters) for programming languages that support overloading have to perform overload resolution, i.e., they have to determine, for a given invocation, which among a set of overloaded methods or constructors is the appropriate or intended one for which executable code should be generated.
Historically, it is common for many such programming languages to require that the arguments to an invocation (e.g., an invocation of an overloaded method) be completely typed (i.e., that the types of all the arguments be determined) before the invocation can itself be typed by the compiler. However, the type of many constructs that are of increasing interest to programmers, and are therefore being considered for inclusion in various programming languages, such as lambda expressions, may be context-dependent—that is, the type of the construct may differ, depending on the surrounding context in which the construct is used. For example, the same lambda expression “( )→“done”” has different types in the following two contexts:
1.Callable<String> c = ( ) → “done”;2.PrivilegedAction<String> a = ( ) → “done”;
This may present difficulties when a programming language is to support the use of such constructs as arguments to methods or constructors. Traditionally, the overload resolution component of a compiler relied upon being provided the types of the arguments to an invocation, but such argument type information may not be available when expressions whose type is context-dependent are used as arguments.